<?php
//error_reporting(0);
include("../include/imageThumb.class.php");
include("../include/upload.class.php");
include("../function.php");
$upload=new uploadFile();

$upload->files= $_FILES['up_image'];
$upload->max_size='2000000';
$upload->uploaded="/cache/".$_SESSION['login_admin'];
$upload->allow_types="jpeg|jpg|png|JPEG|JPG|PNG|gif|GIF";
$upload->save_path="../cache/";
$upload->file_name=$_SESSION['login_admin'];
$upload->upload_file($_FILES['up_image']);

if($upload->errmsg != ""){
	$err=$upload->errmsg;
	echo "<script language=\"javascript\">alert('$err');</script>";
	//echo "<script language=\"javascript\">history.go(-1);</script>";
}else{
	$pictureup=$upload->uploaded;
	$name = 'product_image/'.$_SESSION['login_admin'].time().'.'.$upload->ext; 
	copy('../cache/'.$pictureup,'../'.$name);
	unlink('../cache/'.$pictureup);
	mysql_query("INSERT INTO speed_image (path,create_time,create_user) VALUES ('$name',now(),'$_SESSION[login_admin]')") or die(mysql_error());
	$x = mysql_query("select @@identity as id");
	$id = mysql_fetch_array($x);
	$id = $id[0];
	echo "<div class='image'>$name</div><div class='id'>$id</div>";
	?>
	<script type='text/javascript' src='../js/jquery-1.7.2.min.js'></script>
	<script type='text/javascript'>
		var html = '<div class="pro_image"><img src="../'+$(".image").text()+'"><input type="hidden"name="image[]" value="'+$(".id").text()+'"><a class="del_image">删除</a></div>';
		$(window.parent.document).find("#pro_image").append(html);
		//alert("上传成功");
	</script>
	
<?php
}

?>